#ifndef message_h
#define message_h

#include <stdint.h>

#include "device.h"

#include "cJSON.h"

typedef enum {
	device_to_server,
	server_to_device,
} message_type;

typedef enum {
	connection_none,
	connection_bluetooth,
	connection_lora,
	connection_mqtt,
} connection;

typedef struct {
	message_type message_type;
	connection connection;
	char *device_name;
	char *topic;
	uint32_t timestamp;
	uint32_t size;
	void *content;
} message;

message *message_from_json(message *message, const cJSON *json);
cJSON *message_to_json(cJSON *json, const message *message);
message *message_destory(message *message);

void message_display(const message *message);

#endif